package com.google.code.netbuilder.example.jpa;

import com.google.code.netbuilder.dal.entities.Equipment;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class EquipmentDAO {

    @PersistenceContext(unitName = "NetBuilder")
    EntityManager em;
    
    public Equipment createEquipment(String name, String address) {
        Equipment e = new Equipment();
        e.setName(name);
        e.setAddress(address);
        em.persist(e);
        return e;
    }
    
    public Equipment findEquipment(long id) {
        Equipment e = em.find(Equipment.class, id);
        return e;
    }
}
